package com.ringtheweb.common.util.crypto;

import com.ringtheweb.common.util.Assert;
import com.ringtheweb.common.util.StringUtils;


/**
 * CC validation using the Luhn algorithm
 * 
 * @author ldewavri
 * 
 */
public class CheckCBLuhn {

	 /**
	 * Check that a CC number is valid
	 *
	 * @param creditCardNumber
	 * @return true if valid, false otherwise
	 */
	public static Boolean isValid (String creditCardNumber) {
		
		// Verify entry parameters
		Assert.isTrue(!StringUtils.isEmpty(creditCardNumber),"CC number can not be null");
		
		
		// verify the Luhn key
		Boolean valid = CheckLuhn.isValid(creditCardNumber);
		
		return valid;
	 }
}
